<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'download.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body background="img/4561.jpg">
    <form name="form1" action="DoDownLoadServlet" method="post">
      <table border="2" align="center" bordercolor="pink">
        <tr>
         <td>
            <input type="checkbox" name="all" value="" onclick="getAll();"/>
          </td>
         
          <td align="center">
             <font size="5" color="purple">下载列表</font>
          </td>
        </tr>
      <c:forEach var="file" items="${list}">
        <tr>
          <td>
            <input type="checkbox" name="one" value="${file }"/>
          </td>
          <td>
            ${file }
          </td>
        </tr>
      </c:forEach>
      <tr>
         <td align="center" colspan="2">
             <input type="submit" name="sb" value="下载所选" onclick="return chek();"/>
             <a href="doShowList">点此返回</a>
          </td>
      </tr>
      </table>
    </form>
  </body>
  <script type="text/javascript">
  function getAll(){
	  var all=document.getElementById("all");
	  var ones=document.getElementsByName("one");
	  for(var i=0;i<ones.length;i++){
		  if(all.checked){
			  ones[i].checked=true;
		  }else{
			  ones[i].checked=false;
		  }
	  }
  }
  function chek(){
	  var n=0;
	  var ones=document.getElementsByName("one");
	  for(var i=0;i<ones.length;i++){
		  if(ones[i].checked){
			  n++;
		  }
	  }
	  if(n==0){
		  alert("请选择!");
		  return false;
	  }else{
		  return true;
	  }
  }
  </script>
</html>
